Xbasic

SQL::ConnectionGenerateRetrieveRowQuery Method

Syntax

Statement as C = GenerateRetrieveRowQuery as C (TableInfo as SQL::TableInfo, [, Rows = 1 as N [, LocalTableInfo as SQL::TableInfo,]])

Arguments

TableInfoSQL::TableInfo

A SQL::TableInfo object created by a DIM statement and for the table.

RowsNumeric

Default = 1. The number of rows to return. Multiple rows are returned in a collection.

LocalTableInfoSQL::TableInfo

SQL::TableInfo

Returns

StatementCharacter

A SQL SELECT statement.

If Rows is greater than 1 then a set of of arguments will be generated for each row in the following format:

<Column_name> + "_" + RowNumber

For example, CustomerID becomes:

CustomerID_1
CustomerID_2

If the length of the column name exceeds 20 characters, it is truncated to 20 characters to be sure the extra characters will not exceed the maximum length of a valid field.

If the table has no primary key, GenerateRetrieveRowQuery is meaningless and no string is returned.

Description

Generate a SQL statement to retrieve a specific row for the table passed in. Key columns are generated as arguments.

The SQL::Connection::GenerateRetrieveRowQuery()generates a SQL SELECT statement to fetch a specific row based on the primary key values for the table. If the table has no primary key columns, an empty string is returned.

Once the query is created, you can execute it by providing a SQL::Arguments collection with values populated for the primary key columns.

If Rows is greater than 1, GenerateRetrieveRowQuery()will create a query with multiple rows of values in the WHERE clause.

The names of the key columns will be modified to reflect the row number using the format + "_" + RowNumber. (If the length of the column name exceeds 20 characters, it is truncated to 20 characters to be sure the extra characters will not exceed the maximum length of a valid field. You must set up the arguments collection accordingly.

Example

dim conn as SQL::Connection
dim connString as C
dim ti as SQL::TableInfo
connString = "{A5API='Access', FileName='c:\program files\a5v8\mdbfiles\alphasports.mdb'}"
if .not. conn.open(connString)
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
if .not. conn.GetTableInfo(ti, "customer")
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
ui_msg_box("Row Qualifiers", conn.GenerateRetrieveRowQuery(ti))
conn.close()

See Also